home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Atari Compendium
/
The Atari Compendium (Toad Computers) (1994).iso
/
files
/
umich
/
utils
/
scrnsvrs
/
scrnsavr.lzh
/
Faze.S
< prev
next >
Wrap
Text File
|
1992-05-12
|
17KB
|
546 lines
*-------------------------------------*
* -F-A-Z-E- Screen Saver *
* by Damien M. Jones *
* Version 1.00 *
*-------------------------------------*
* This screen saver is built around a generic screen saver
* frame. The frame hooks into the VBL and KBD/MIDI interrupts,
* displays a successful installation message, and then terminates
* with ptermres.
*
* I've gone through (May 12, 1992) and added extra comments to
* clear up some confusion. The separate parts of the program
* have been more clearly labeled. If you don't like the way
* I format my assembly, tough; I write it for me, not for you.
* Code begins.
* Generic Screen Saver
* by Damien M. Jones
* Copyright 1992 Damien M. Jones, All Rights Reserved.
*
* Just change the "saver" routine to change the screen saver.
* Please include a note in your documentation that you used
* the "Generic Screen Saver Frame by dmj"; I place no other
* restrictions on the use of this code. So you could release
* a Shareware screen saver using this code, and you wouldn't
* have to send me a penny. A copy of the screensaver would
* be nice, but not mandatory.
* If you leave the "id" string as it is, you can use the BoinkCfg
* program to set the time delay for the screen saver, as well
* as disable it. Otherwise, you'll have to write your own
* config program.
* You'll need to change the amount of memory to save, around line
* 182. Faze uses a 32K screen, plus space for the program.
jmp install ; Install program.
* Variables (for the config program).
id dc.b 'dmjScreenSaver' ; Fourteen-byte ID string.
ssave dc.w 0 ; Old screen address.
screen dc.w 0 ; Address of screen saver screen.
timeout dc.w 300 ; Default is two minutes.
count dc.w 300 ; Number of cycles left to wait.
flag dc.w 0 ; Set if screen saver active.
palsave dc.w 0,0,0,0,0,0,0,0 ; Place to store system palette.
dc.w 0,0,0,0,0,0,0,0
rezsave dc.w 0 ; Place to store system resolution.
pal dc.w $000,$722,$631,$540,$450,$361,$272,$163 ; Screensaver palette.
dc.w $054,$045,$136,$227,$316,$405,$504,$613
rez dc.w 0 ; Resolution of screen saver.
rndseed dc.l $31415926 ; Random number generator seed.
* The VBL. Decrements timer, then checks to see if screen saver
* needs to be activated. It then jumps to the OS VBL.
vbl tst.w flag ; Is the screen saver active?
beq vskip ; No, need to check counter.
jsr saver ; Call the screen save subroutine.
bra jmp1 ; All done.
vskip move.l a0,-(a7) ; Save this register.
move.l #count,a0 ; Address of count variable.
subq.w #1,(a0) ; Decrement counter.
tst.w (a0)+ ; Is it zero?
bne vblend ; Nope, exit now.
st (a0) ; Set in-use flag.
movem.l d0/a1,-(a7) ; Save these register too.
lea $FFFF8240.w,a1 ; Address of palette registers.
move.l #palsave,a0 ; Address to save into.
move.l (a1)+,(a0)+ ; Save palette.
move.l (a1)+,(a0)+
move.l (a1)+,(a0)+
move.l (a1)+,(a0)+
move.l (a1)+,(a0)+
move.l (a1)+,(a0)+
move.l (a1)+,(a0)+
move.l (a1)+,(a0)+
move.w (a1)+,(a0)+ ; Resolution.
lea $FFFF8240.w,a1 ; Address of palette registers.
move.l (a0)+,(a1)+ ; Move in saver palette.
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.b (a0),(a1) ; And saver resolution.
lea $FFFF8201.w,a1 ; Screen address vars in Shifter.
move.l #ssave,a0 ; Address of variable.
movep.w 0(a1),d0 ; Read old value.
move.w d0,(a0)+ ; And save it.
move.w (a0),d0 ; Get saver screen address.
movep.w d0,0(a1) ; Copy over address.
movem.l (a7)+,d0/a1 ; Restore registers.
vblend move.l (a7)+,a0 ; Restore register.
jmp1 jmp $11111111 ; Jump to old VBL.
* The keyboard interrupt. Resets VBL timer, and shuts off screen
* saver if it's active.
kbd move.l a0,-(a7) ; Save this register.
move.l #timeout,a0 ; Address of variable.
move.w (a0)+,(a0)+ ; Copy over word.
tst.w (a0)+ ; Was the screen saver active?
beq kbdend ; No, exit now.
movem.l d0/a1,-(a7) ; Save these registers too.
lea $FFFF8240.w,a1 ; Address of palette registers.
move.l (a0)+,(a1)+ ; Restore palette.
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.l (a0)+,(a1)+
move.b (a0),(a1) ; Restore resolution.
lea $FFFF8201.w,a1 ; Screen address vars in Shifter.
move.l #ssave,a0 ; Address of variable.
move.w (a0),d0 ; Get contents.
movep.w d0,0(a1) ; Copy over address.
clr.w flag ; Clear this flag.
movem.l (a7)+,d0/a1 ; Restore these registers.
kbdend move.l (a7)+,a0 ; Restore register.
jmp2 jmp $11111111 ; Jump to old KBD.
* The installation routine. Displays install message, hooks into
* KBD/MIDI and VBL, and exits with ptermres.
install pea initmsg ; Address of text.
move.w #9,-(a7) ; cconws
trap #1 ; GEMDOS(9)
addq.l #6,a7 ; Adjust stack.
move.w #4,-(a7) ; getrez
trap #14 ; XBIOS(4)
addq.l #2,a7 ; Adjust stack.
cmp.b #2,d0 ; High resolution?
bne color ; No, install and exit.
pea errmsg ; Address of text.
move.w #9,-(a7) ; cconws
trap #1 ; GEMDOS(9)
addq.l #6,a7 ; Adjust stack.
clr.w -(a7) ; pterm0
trap #1 ; GEMDOS(0) - No return.
color pea init ; Address of init routine.
move.w #38,-(a7) ; supexec
trap #14 ; XBIOS(38)
addq.l #6,-(a7) ; Adjust stack.
bsr sinit ; Init Screen Saver.
pea okmsg ; Address of text.
move.w #9,-(a7) ; cconws
trap #1 ; GEMDOS(9)
addq.l #6,a7 ; Adjust stack.
move.l #34080,-(a7) ; Save 33K for program & screen.
move.w #49,-(a7) ; ptermres
trap #1 ; GEMDOS(49) - No return.
* This actually hooks the interrupts.
init movem.l d0/a0,-(a7) ; Save this register.
move.w sr,-(a7) ; Save status register.
move.w #$2700,sr ; No interruptions.
move.l #jmp2+2,a0 ; Address of jump instruction.
move.l $118.w,(a0) ; Copy over old keyboard vector.
move.l #kbd,a0 ; Address of KBD routine.
move.l a0,$118.w ; Store it.
move.l #jmp1+2,a0 ; Address of jump instruction.
move.l $70.w,(a0) ; Copy over old VBL vector.
move.l #vbl,a0 ; Address of VBL routine.
move.l a0,$70.w ; Store it.
move.l #svscrn,d0 ; Address of screen area.
add.l #255,d0 ; Round up if necessary.
lsr.l #8,d0 ; Shift that address down.
move.w d0,screen ; Save screen address.
move.w (a7)+,sr ; Restore status register.
movem.l (a7)+,d0/a0 ; Restore this register.
rts ; Return.
* Init custom to FAZE. Different screen savers will require
* different init code here.
sinit clr.l d0 ; Make sure all of this is clear.
move.w screen,d0 ; Get screen address.
lsl.l #8,d0 ; Shift it to get real address.
move.l d0,a0 ; Copy to address register.
move.w #7679,d1 ; Number of words.
move.l #-1,d2 ; Word to move.
siloop move.l d2,(a0)+ ; Store word.
dbra d1,siloop ; Next long.
rts ; All done.
* The actual saver routine; it makes the screen saver what it is.
* This routine, the one above it, and the amount of memory to
* save on line 182 are all you need to change to make a different
* screen saver.
* -F-A-Z-E- Screen Save Routine
* by Damien M. Jones
* Copyright 1992 Damien M. Jones, All Rights Reserved.
* Basically, this program picks a random point from 0,0 to 31,31.
* It then checks the adjacent four points. If any of these are
* in the next lower color, nothing is done. Otherwise, if two
* of the connecting points are of the next higher color, then
* the point is plotted in that next higher color. Otherwise it
* has a 20% chance of being plotted in that next higher color.
* Colors wrap, so 1 is the next higher color after 15.
* Only one point is tested per VBL. This routine takes about
* 11% of processor time.
saver movem.l d0-d7/a0-a2,-(a7) ; Save registers.
bsr rnd ; Randomize.
clr.l d0 ; Make sure all of this is clear.
move.w screen,d0 ; Get screen address.
lsl.l #8,d0 ; Shift it to get real address.
move.l d0,a0 ; Copy to address register.
Faze bsr rnd ; Get